package engine.audio;

/**
 * Channel
 * An audio buffer that has an attached oscillator.
 * Used by AudioManager for generating and mixing of sound synthesis.
 **/
public final class Channel extends AudioBuffer {
	/**
	 * CtoR
	 * @param name - A name this channel can be looked up by.
	 * @param bufferSize - The size of the AudioBuffer in bytes.
	 **/
	public Channel(String name, int bufferSize) {
		super(bufferSize);
		_Name = name;
	}
	public Oscillator_I Oscillator;
	private final String _Name;
	/**
	 * @return The name of this Channel
	 **/
	public String getName() {
		return _Name;
	}
	/**
	 * Tells the attached Oscillator to generate into this buffer.
	 * @param sampleCount - the number of samples to generate.
	 * @return the number of samples generated.
	 **/
	public int generate(int sampleCount) {
		this.clear();
		if(Oscillator == null) {
			return 0;
		}
		return Oscillator.generate(this, sampleCount);
	}
}